package com.lzcu.maoyan.mapreduce.mapreduce.unit;

import org.apache.hadoop.mapreduce.lib.db.DBWritable;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author WangLiang
 * @date `2024/4/24`
 */
public class MovieTypeWritable implements DBWritable {
    private String movieType;
    private int count;
    private String sourceMovieType;
    private String sourceMovieName;
    private String movieName;
    private long totalSessions;

    @Override
    public void write(PreparedStatement statement) throws SQLException {
        statement.setString(1, this.movieType);
        statement.setDouble(2, this.count);
        statement.setString(3, this.movieName);
        statement.setLong(4, this.totalSessions);
    }

    @Override
    public void readFields(ResultSet resultSet) throws SQLException {
        this.sourceMovieType = resultSet.getString("SOURCE_MOVIE_TYPE");
        this.sourceMovieName = resultSet.getString("SOURCE_MOVIE_NAME");
    }

    public String getMovieType() {
        return movieType;
    }

    public void setMovieType(String movieType) {
        this.movieType = movieType;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getSourceMovieType() {
        return sourceMovieType;
    }

    public void setSourceMovieType(String sourceMovieType) {
        this.sourceMovieType = sourceMovieType;
    }

    public String getSourceMovieName() {
        return sourceMovieName;
    }

    public void setSourceMovieName(String sourceMovieName) {
        this.sourceMovieName = sourceMovieName;
    }

    public String getMovieName() {
        return movieName;
    }

    public void setMovieName(String movieName) {
        this.movieName = movieName;
    }

    public long getTotalSessions() {
        return totalSessions;
    }

    public void setTotalSessions(long totalSessions) {
        this.totalSessions = totalSessions;
    }
}
